
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Geographic Feeds &#8212; Django 2.2.12.dev20200304094918 documentation</title>
    <link rel="stylesheet" href="../../../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
    <script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../../../_static/jquery.js"></script>
    <script type="text/javascript" src="../../../_static/underscore.js"></script>
    <script type="text/javascript" src="../../../_static/doctools.js"></script>
    <script type="text/javascript" src="../../../_static/language_data.js"></script>
    <link rel="index" title="Index" href="../../../genindex.html" />
    <link rel="search" title="Search" href="../../../search.html" />
    <link rel="next" title="Geographic Sitemaps" href="sitemaps.html" />
    <link rel="prev" title="GeoDjango’s admin site" href="admin.html" />



 
<script type="text/javascript" src="../../../templatebuiltins.js"></script>
<script type="text/javascript">
(function($) {
    if (!django_template_builtins) {
       // templatebuiltins.js missing, do nothing.
       return;
    }
    $(document).ready(function() {
        // Hyperlink Django template tags and filters
        var base = "../../templates/builtins.html";
        if (base == "#") {
            // Special case for builtins.html itself
            base = "";
        }
        // Tags are keywords, class '.k'
        $("div.highlight\\-html\\+django span.k").each(function(i, elem) {
             var tagname = $(elem).text();
             if ($.inArray(tagname, django_template_builtins.ttags) != -1) {
                 var fragment = tagname.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + tagname + "</a>");
             }
        });
        // Filters are functions, class '.nf'
        $("div.highlight\\-html\\+django span.nf").each(function(i, elem) {
             var filtername = $(elem).text();
             if ($.inArray(filtername, django_template_builtins.tfilters) != -1) {
                 var fragment = filtername.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + filtername + "</a>");
             }
        });
    });
})(jQuery);</script>

  </head><body>

    <div class="document">
  <div id="custom-doc" class="yui-t6">
    <div id="hd">
      <h1><a href="../../../index.html">Django 2.2.12.dev20200304094918 documentation</a></h1>
      <div id="global-nav">
        <a title="Home page" href="../../../index.html">Home</a>  |
        <a title="Table of contents" href="../../../contents.html">Table of contents</a>  |
        <a title="Global index" href="../../../genindex.html">Index</a>  |
        <a title="Module index" href="../../../py-modindex.html">Modules</a>
      </div>
      <div class="nav">
    &laquo; <a href="admin.html" title="GeoDjango’s admin site">previous</a>
     |
    <a href="../../index.html" title="API Reference" accesskey="U">up</a>
   |
    <a href="sitemaps.html" title="Geographic Sitemaps">next</a> &raquo;</div>
    </div>

    <div id="bd">
      <div id="yui-main">
        <div class="yui-b">
          <div class="yui-g" id="ref-contrib-gis-feeds">
            
  <div class="section" id="s-module-django.contrib.gis.feeds">
<span id="s-geographic-feeds"></span><span id="module-django.contrib.gis.feeds"></span><span id="geographic-feeds"></span><h1>Geographic Feeds<a class="headerlink" href="#module-django.contrib.gis.feeds" title="Permalink to this headline">¶</a></h1>
<p>GeoDjango has its own <a class="reference internal" href="#django.contrib.gis.feeds.Feed" title="django.contrib.gis.feeds.Feed"><code class="xref py py-class docutils literal notranslate"><span class="pre">Feed</span></code></a> subclass that may embed location information
in RSS/Atom feeds formatted according to either the <a class="reference external" href="http://georss.org/simple.html">Simple GeoRSS</a> or
<a class="reference external" href="https://www.w3.org/2003/01/geo/">W3C Geo</a> standards.  Because GeoDjango’s syndication API is a superset of
Django’s, please consult <a class="reference internal" href="../syndication.html"><span class="doc">Django’s syndication documentation</span></a> for details on general usage.</p>
<div class="section" id="s-example">
<span id="example"></span><h2>Example<a class="headerlink" href="#example" title="Permalink to this headline">¶</a></h2>
</div>
<div class="section" id="s-api-reference">
<span id="api-reference"></span><h2>API Reference<a class="headerlink" href="#api-reference" title="Permalink to this headline">¶</a></h2>
<div class="section" id="s-feed-subclass">
<span id="feed-subclass"></span><h3><code class="docutils literal notranslate"><span class="pre">Feed</span></code> Subclass<a class="headerlink" href="#feed-subclass" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.contrib.gis.feeds.Feed">
<em class="property">class </em><code class="descname">Feed</code><a class="reference internal" href="../../../_modules/django/contrib/gis/feeds.html#Feed"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.contrib.gis.feeds.Feed" title="Permalink to this definition">¶</a></dt>
<dd><p>In addition to methods provided by the
<a class="reference internal" href="../syndication.html#django.contrib.syndication.views.Feed" title="django.contrib.syndication.views.Feed"><code class="xref py py-class docutils literal notranslate"><span class="pre">django.contrib.syndication.views.Feed</span></code></a> base class, GeoDjango’s
<code class="docutils literal notranslate"><span class="pre">Feed</span></code> class provides the following overrides. Note that these overrides
may be done in multiple ways:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">django.contrib.gis.feeds</span> <span class="k">import</span> <span class="n">Feed</span>

<span class="k">class</span> <span class="nc">MyFeed</span><span class="p">(</span><span class="n">Feed</span><span class="p">):</span>

    <span class="c1"># First, as a class attribute.</span>
    <span class="n">geometry</span> <span class="o">=</span> <span class="o">...</span>
    <span class="n">item_geometry</span> <span class="o">=</span> <span class="o">...</span>

    <span class="c1"># Also a function with no arguments</span>
    <span class="k">def</span> <span class="nf">geometry</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="o">...</span>

    <span class="k">def</span> <span class="nf">item_geometry</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="o">...</span>

    <span class="c1"># And as a function with a single argument</span>
    <span class="k">def</span> <span class="nf">geometry</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">obj</span><span class="p">):</span>
        <span class="o">...</span>

    <span class="k">def</span> <span class="nf">item_geometry</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">item</span><span class="p">):</span>
        <span class="o">...</span>
</pre></div>
</div>
<dl class="method">
<dt id="django.contrib.gis.feeds.Feed.geometry">
<code class="descname">geometry</code>(<em>obj</em>)<a class="headerlink" href="#django.contrib.gis.feeds.Feed.geometry" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Takes the object returned by <code class="docutils literal notranslate"><span class="pre">get_object()</span></code> and returns the <em>feed’s</em>
geometry. Typically this is a <code class="docutils literal notranslate"><span class="pre">GEOSGeometry</span></code> instance, or can be a tuple
to represent a point or a box. For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">ZipcodeFeed</span><span class="p">(</span><span class="n">Feed</span><span class="p">):</span>

    <span class="k">def</span> <span class="nf">geometry</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">obj</span><span class="p">):</span>
        <span class="c1"># Can also return: `obj.poly`, and `obj.poly.centroid`.</span>
        <span class="k">return</span> <span class="n">obj</span><span class="o">.</span><span class="n">poly</span><span class="o">.</span><span class="n">extent</span> <span class="c1"># tuple like: (X0, Y0, X1, Y1).</span>
</pre></div>
</div>
<dl class="method">
<dt id="django.contrib.gis.feeds.Feed.item_geometry">
<code class="descname">item_geometry</code>(<em>item</em>)<a class="headerlink" href="#django.contrib.gis.feeds.Feed.item_geometry" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Set this to return the geometry for each <em>item</em> in the feed. This can be a
<code class="docutils literal notranslate"><span class="pre">GEOSGeometry</span></code> instance, or a tuple that represents a point coordinate or
bounding box. For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">ZipcodeFeed</span><span class="p">(</span><span class="n">Feed</span><span class="p">):</span>

    <span class="k">def</span> <span class="nf">item_geometry</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">obj</span><span class="p">):</span>
        <span class="c1"># Returns the polygon.</span>
        <span class="k">return</span> <span class="n">obj</span><span class="o">.</span><span class="n">poly</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="s-syndicationfeed-subclasses">
<span id="syndicationfeed-subclasses"></span><h3><code class="docutils literal notranslate"><span class="pre">SyndicationFeed</span></code> Subclasses<a class="headerlink" href="#syndicationfeed-subclasses" title="Permalink to this headline">¶</a></h3>
<p>The following <a class="reference internal" href="../../utils.html#django.utils.feedgenerator.SyndicationFeed" title="django.utils.feedgenerator.SyndicationFeed"><code class="xref py py-class docutils literal notranslate"><span class="pre">django.utils.feedgenerator.SyndicationFeed</span></code></a> subclasses
are available:</p>
<dl class="class">
<dt id="django.contrib.gis.feeds.GeoRSSFeed">
<em class="property">class </em><code class="descname">GeoRSSFeed</code><a class="reference internal" href="../../../_modules/django/contrib/gis/feeds.html#GeoRSSFeed"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.contrib.gis.feeds.GeoRSSFeed" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="class">
<dt id="django.contrib.gis.feeds.GeoAtom1Feed">
<em class="property">class </em><code class="descname">GeoAtom1Feed</code><a class="reference internal" href="../../../_modules/django/contrib/gis/feeds.html#GeoAtom1Feed"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.contrib.gis.feeds.GeoAtom1Feed" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="class">
<dt id="django.contrib.gis.feeds.W3CGeoFeed">
<em class="property">class </em><code class="descname">W3CGeoFeed</code><a class="reference internal" href="../../../_modules/django/contrib/gis/feeds.html#W3CGeoFeed"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.contrib.gis.feeds.W3CGeoFeed" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last"><a class="reference external" href="https://www.w3.org/2003/01/geo/">W3C Geo</a> formatted feeds only support
<a class="reference internal" href="model-api.html#django.contrib.gis.db.models.PointField" title="django.contrib.gis.db.models.PointField"><code class="xref py py-class docutils literal notranslate"><span class="pre">PointField</span></code></a> geometries.</p>
</div>
</div>
</div>
</div>


          </div>
        </div>
      </div>
      
        
          <div class="yui-b" id="sidebar">
            
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../../../contents.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Geographic Feeds</a><ul>
<li><a class="reference internal" href="#example">Example</a></li>
<li><a class="reference internal" href="#api-reference">API Reference</a><ul>
<li><a class="reference internal" href="#feed-subclass"><code class="docutils literal notranslate"><span class="pre">Feed</span></code> Subclass</a></li>
<li><a class="reference internal" href="#syndicationfeed-subclasses"><code class="docutils literal notranslate"><span class="pre">SyndicationFeed</span></code> Subclasses</a></li>
</ul>
</li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="admin.html"
                        title="previous chapter">GeoDjango’s admin site</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="sitemaps.html"
                        title="next chapter">Geographic Sitemaps</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../../../_sources/ref/contrib/gis/feeds.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../../../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
              <h3>Last update:</h3>
              <p class="topless">Mar 04, 2020</p>
          </div>
        
      
    </div>

    <div id="ft">
      <div class="nav">
    &laquo; <a href="admin.html" title="GeoDjango’s admin site">previous</a>
     |
    <a href="../../index.html" title="API Reference" accesskey="U">up</a>
   |
    <a href="sitemaps.html" title="Geographic Sitemaps">next</a> &raquo;</div>
    </div>
  </div>

      <div class="clearer"></div>
    </div>
  </body>
</html>